import { User } from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    const token = ref('')
    const userInfo = ref({} as User)

    const setToken = (value: string) => {
      token.value = value
    }

    const setUser = (value: User) => {
      userInfo.value = value
    }

    return {
      token,
      userInfo,
      setToken,
      setUser
    }
  },
  {
    persist: true
  }
)
